namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _20200525001newMoBan : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.MoBan_Main",
                c => new
                    {
                        mbid = c.Int(nullable: false, identity: true),
                        mbmc = c.String(),
                        cjsj = c.DateTime(nullable: false),
                        cjr = c.Guid(nullable: false),
                        mbtype = c.Int(nullable: false),
                        isuse = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.mbid);
            
            CreateTable(
                "dbo.MoBan_Path",
                c => new
                    {
                        ljid = c.Int(nullable: false, identity: true),
                        shunxu = c.Int(nullable: false),
                        ljmc = c.String(),
                        pid = c.Int(nullable: false),
                        paths = c.String(),
                        fenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        MoBanMain_mbid = c.Int(),
                    })
                .PrimaryKey(t => t.ljid)
                .ForeignKey("dbo.MoBan_Main", t => t.MoBanMain_mbid)
                .Index(t => t.MoBanMain_mbid);
            
            CreateTable(
                "dbo.MoBan_Content",
                c => new
                    {
                        nrid = c.Int(nullable: false, identity: true),
                        shunxu = c.Int(nullable: false),
                        nr = c.String(),
                        fenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        ControlID = c.Int(nullable: false),
                        MoBanPath_ljid = c.Int(),
                    })
                .PrimaryKey(t => t.nrid)
                .ForeignKey("dbo.MoBan_Path", t => t.MoBanPath_ljid)
                .Index(t => t.MoBanPath_ljid);
            
            CreateTable(
                "dbo.MoBan_Answer",
                c => new
                    {
                        aid = c.Int(nullable: false, identity: true),
                        shunxu = c.Int(nullable: false),
                        tips = c.String(),
                        fenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        html = c.String(),
                        MoBanContent_nrid = c.Int(),
                    })
                .PrimaryKey(t => t.aid)
                .ForeignKey("dbo.MoBan_Content", t => t.MoBanContent_nrid)
                .Index(t => t.MoBanContent_nrid);
            
            CreateTable(
                "dbo.MoBan_Control",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        controlname = c.String(),
                        controlhtml = c.String(),
                    })
                .PrimaryKey(t => t.id);
            
            CreateTable(
                "dbo.MoBan_MainZhiWei",
                c => new
                    {
                        MoBan_Main_mbid = c.Int(nullable: false),
                        ZhiWei_zwid = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.MoBan_Main_mbid, t.ZhiWei_zwid })
                .ForeignKey("dbo.MoBan_Main", t => t.MoBan_Main_mbid, cascadeDelete: true)
                .ForeignKey("dbo.ZhiWeis", t => t.ZhiWei_zwid, cascadeDelete: true)
                .Index(t => t.MoBan_Main_mbid)
                .Index(t => t.ZhiWei_zwid);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.MoBan_MainZhiWei", "ZhiWei_zwid", "dbo.ZhiWeis");
            DropForeignKey("dbo.MoBan_MainZhiWei", "MoBan_Main_mbid", "dbo.MoBan_Main");
            DropForeignKey("dbo.MoBan_Path", "MoBanMain_mbid", "dbo.MoBan_Main");
            DropForeignKey("dbo.MoBan_Content", "MoBanPath_ljid", "dbo.MoBan_Path");
            DropForeignKey("dbo.MoBan_Answer", "MoBanContent_nrid", "dbo.MoBan_Content");
            DropIndex("dbo.MoBan_MainZhiWei", new[] { "ZhiWei_zwid" });
            DropIndex("dbo.MoBan_MainZhiWei", new[] { "MoBan_Main_mbid" });
            DropIndex("dbo.MoBan_Answer", new[] { "MoBanContent_nrid" });
            DropIndex("dbo.MoBan_Content", new[] { "MoBanPath_ljid" });
            DropIndex("dbo.MoBan_Path", new[] { "MoBanMain_mbid" });
            DropTable("dbo.MoBan_MainZhiWei");
            DropTable("dbo.MoBan_Control");
            DropTable("dbo.MoBan_Answer");
            DropTable("dbo.MoBan_Content");
            DropTable("dbo.MoBan_Path");
            DropTable("dbo.MoBan_Main");
        }
    }
}
